<script>
	var url<?=$objectid?>;
	$(document).ready(function(){
		
		new_data<?=$objectid?> = function (id){	
			
			var id_angkatan		= $('#s_id_angkatan<?=$objectid?>').val();
			var id_tahunajaran	= $('#s_id_tahunajaran<?=$objectid?>').val();
			var id_tingkat		= $('#s_id_tingkat<?=$objectid?>').val();
			var id_kelas		= $('#s_id_kelas<?=$objectid?>').val();
			
			$('#window<?=$objectid?>').dialog({
				title: 'Penempatan Siswa Baru',
				width: 430,
				height: 360,
				closed: true,
				cache: false,
				href: base_url+'sd/daftar_ulang/add/'+id+'/'+id_angkatan+'/'+id_tahunajaran+'/'+id_tingkat+'/'+id_kelas,
				modal: true,
				style:{background:'#dee5ff'}
			});
			
			$('#window<?=$objectid?>').dialog('open');
			url<?=$objectid?> = base_url+'sd/daftar_ulang/save/add';
		}
		// end new_data
		
/* 	grid asal     --------------------------------------------------------------------------------------------------------------*/
		
		// auto complite
		$('#s_id_psb<?=$objectid?>').change(function(){
			$('#s_id_kelompok<?=$objectid?>').load(base_url+'prosedur/get_gelombang_by_psb/'+$('#s_id_psb<?=$objectid?>').val());
		});
		
		// filter
		filter_asal<?=$objectid?> = function(){
			$('#dg_asal<?=$objectid?>').datagrid('load',{
				id_psb : $('#s_id_psb<?=$objectid?>').val(),
				id_kelompok : $('#s_id_kelompok<?=$objectid?>').val(),
			});
			//$('#dg').datagrid('enableFilter');
		}
		
		// button aksi
		actionbutton_asal<?=$objectid?> = function(value, row, index){
			var col="";
			col += '<a href="#" onclick="new_data<?=$objectid?>(\''+row.id+'\');" class="easyui-linkbutton" iconCls="icon-edit" plain="false">Daftar</a>';
			return col;
		}
		
		// init grid
		$(function(){
			$('#dg_asal<?=$objectid?>').datagrid({
				url:"<?=base_url()?>sd/daftar_ulang/grid_calon_siswa"
			});
		});
/* 	end grid asal --------------------------------------------------------------------------------------------------------------*/


/* 	grid tujuan     --------------------------------------------------------------------------------------------------------------*/
		
		// auto complite
		$('#s_id_psb<?=$objectid?>').change(function(){
			$('#s_id_kelompok<?=$objectid?>').load(base_url+'prosedur/get_gelombang_by_psb/'+$('#s_id_psb<?=$objectid?>').val());
		});
		
		// filter
		filter_tujuan<?=$objectid?> = function(){
			$('#dg_tujuan<?=$objectid?>').datagrid('load',{
				id_psb : $('#s_id_psb<?=$objectid?>').val(),
				id_kelompok : $('#s_id_kelompok<?=$objectid?>').val(),
			});
			//$('#dg').datagrid('enableFilter');
		}
		
		// button aksi
		// actionbutton_tujuan<?=$objectid?> = function(value, row, index){
			// var col="";
			// col += '<a href="#" onclick="editData<?=$objectid?>(\''+row.id+'\');" class="easyui-linkbutton" iconCls="icon-edit" plain="false">Daftar</a>';
			// return col;
		// }
		
		// init grid
		$(function(){
			$('#dg_tujuan<?=$objectid?>').datagrid({
				url:"<?=base_url()?>sd/daftar_ulang/grid_calon_siswa"
			});
		});
/* 	end grid tujuan --------------------------------------------------------------------------------------------------------------*/
		
		
	});
</script>

<div class="easyui-layout" fit="true">
	<div data-options="region:'west',split:true,title:'Data Calon Siswa',collapsible:false" style="width:50%;">
		<table id="dg_asal<?=$objectid?>" title="" data-options="
					rownumbers:true,
					singleSelect:true,
					autoRowHeight:false,
					pagination:true,
					pageSize:30,
					fit:true,
					toolbar:'#toolbar_asal<?=$objectid?>',
					">
			<thead>
				<tr>
					<th field="id" width="100" hidden="true"></th>
					<th field="no_pendaftaran" width="120">No. Pendaftaran</th>
					<th field="nama" width="180">Nama Calon</th>
					<th field="jk" width="50">JK</th>
					<th field="action" align="center" formatter="actionbutton_asal<?=$objectid?>" width="70">Aksi</th>
				</tr>
			</thead>
		</table>
		<div id="toolbar_asal<?=$objectid?>" style="padding:0px;height:auto">
			<div class="fsearch">
				<div>
					<table width="100%" border="0" cellpadding="3" cellspacing="3">
					  <tr>
						<td width="130px">Proses penerimaan</td>
						<td>: 
							<select name="s_id_psb" id="s_id_psb<?=$objectid?>" style="width:230px;">
								<?=$this->mdl_prosedur->option_proses_penerimaan();?>
							</select>
						</td>
					  </tr>
					  <tr>
						<td>Gelombang</td>
						<td>: 
							<select name="s_id_kelompok" id="s_id_kelompok<?=$objectid?>" style="width:230px;">
								<?=$this->mdl_prosedur->option_kelompok_penerimaan()?>
							</select>
						</td>
					  </tr>
					  <tr>
						<td>&nbsp;</td>				
						<td>&nbsp;&nbsp;<a href="#" onclick="filter_asal<?=$objectid?>()" class="easyui-linkbutton" iconCls="icon-search" style="width:100px;">Filter</a></td>
					  </tr>
					</table>
				</div>
			</div>
		</div>
	</div>
	
	
	
	<div data-options="region:'center', title:'Penempatan Siswa'">
		<table id="dg_tujuan<?=$objectid?>" title="" data-options="
					rownumbers:true,
					singleSelect:true,
					autoRowHeight:false,
					pagination:true,
					pageSize:30,
					fit:true,
					toolbar:'#toolbar_tujuan<?=$objectid?>',
					">
			<thead>
				<tr>
					<th field="id" width="100" hidden="true"></th>
					<th field="no_pendaftaran" width="120">NIS</th>
					<th field="nama" width="180">Nama Calon</th>
					<th field="jk" width="50">JK</th>
					<th field="jk" width="50">Kelas</th>
				</tr>
			</thead>
		</table>
		<div id="toolbar_tujuan<?=$objectid?>" style="padding:0px;height:auto">
			<div class="fsearch">
				<div>
					<table width="100%" border="0" cellpadding="3" cellspacing="3">
					  <tr>
						<td width="100px">Angkatan</td>
						<td>: 
							<select name="s_id_angkatan" id="s_id_angkatan<?=$objectid?>" style="width:80px;">
								<?=$this->mdl_prosedur->option_angkatan(array('kd_departemen'=>'1'));?>
							</select>
						</td>
					  </tr>
					  <tr>
						<td>Thn. Ajaran</td>
						<td>: 
							<select name="s_id_tahunajaran" id="s_id_tahunajaran<?=$objectid?>" style="width:230px;">
								<?=$this->mdl_prosedur->option_tahun_ajaran(array('kd_departemen'=>'1'))?>
							</select>
						</td>
					  </tr>
					  <tr>
						<td>Tingkat</td>
						<td>: 
							<select name="s_id_tingkat" id="s_id_tingkat<?=$objectid?>" style="width:80px;">
								<?=$this->mdl_prosedur->OptionTingkat(array('kd_departemen'=>'1'))?>
							</select>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							Kelas&nbsp;:&nbsp;
							<select name="s_id_kelas" id="s_id_kelas<?=$objectid?>" style="width:80px;">
								<?=$this->mdl_prosedur->OptionTingkat(array('kd_departemen'=>'1'))?>
							</select>
						</td>
					  </tr>
					  <tr>
						<td>&nbsp;</td>				
						<td>&nbsp;&nbsp;<a href="#" onclick="filter<?=$objectid?>()" class="easyui-linkbutton" iconCls="icon-search" style="width:100px;">Filter</a></td>
					  </tr>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>


<!-- AREA untuk Form Add >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  -->
<div id="window<?=$objectid?>" class="easyui-dialog" style="width:400px;height:150px;" data-options="
		closed:true,
		minimizable:false,
		collapsible:false,
		maximizable:false,
		buttons:'#winbutton<?=$objectid?>',
		onResize:function(){
			$(this).window('center');
		}">
</div>
<div id="winbutton<?=$objectid?>">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="save_daftar_ulang<?=$objectid?>()">Save</a>
	<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#window<?=$objectid?>').dialog('close')">Cancel</a>
</div>